package org.example;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.AsyncConnection;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.util.concurrent.CompletableFuture;

public class HBaseConnection {
    public static void main(String[] args) {
        Configuration configuration = new Configuration();
        configuration.set("hbase.zookeeper.quorum", "hadoop102:2181,hadoop103:2181,hadoop104:2181");

        try (
                Connection connection = ConnectionFactory.createConnection(configuration);
                ) {
            CompletableFuture<AsyncConnection> asyncConnection =
                    ConnectionFactory.createAsyncConnection(configuration);

            Admin admin = connection.getAdmin();

            NamespaceDescriptor build = NamespaceDescriptor.create("fengliulinNamespace")
                    .addConfiguration("feng", "value")
                    .build();

            admin.createNamespace(build);

            System.out.println(admin);


            System.out.println(connection);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}